#include <bits/stdc++.h>
using namespace std;
#define yes cout << "YES" << endl
#define no cout << "NO" << endl
using ll = long long;
ll solve()
{
    string s;
    cin >> s;
    if (s.size() < 6)
    {
        return 0;
    }
    ll len = 6, ans = 0;
    for (ll i = 0; i <= s.size() - 6; i++)
    {
        // cout << s.substr(i, 6) << endl;
        if (s.substr(i, 6) == "matiji")
        {
            ans++;
        }
    }
    return ans;
}
int main()
{
    int t = 1;
    // cin >> t;
    while (t--)
    {
        cout << solve();
    }
    return 0;
}
